package com.ruoyi.project.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.domain.entity.ProjectMatching;
import com.ruoyi.project.domain.entity.ProjectOperLog;
import com.ruoyi.project.mapper.ProjectMatchingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.mapper.ProjectOperLogMapper;
import com.ruoyi.project.service.IProjectOperLogService;

/**
 * 操作日志记录Service业务层处理
 * 
 * @author zzy
 * @date 2025-10-23
 */
@Service
public class ProjectOperLogServiceImpl extends ServiceImpl<ProjectOperLogMapper, ProjectOperLog> implements IProjectOperLogService
{
    @Autowired
    private ProjectOperLogMapper projectOperLogMapper;

    /**
     * 查询操作日志记录
     * 
     * @param id 操作日志记录主键
     * @return 操作日志记录
     */
    @Override
    public ProjectOperLog selectProjectOperLogById(Long id)
    {
        return projectOperLogMapper.selectById(id);
    }

    /**
     * 查询操作日志记录列表
     * 
     * @param projectOperLog 操作日志记录
     * @return 操作日志记录
     */
    @Override
    public List<ProjectOperLog> selectProjectOperLogList(ProjectOperLog projectOperLog)
    {
        LambdaQueryWrapper<ProjectOperLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(StringUtils.isNotEmpty(projectOperLog.getOperator()), ProjectOperLog::getOperator, projectOperLog.getOperator());
        wrapper.orderByDesc(ProjectOperLog::getCreateTime);
        return projectOperLogMapper.selectList(wrapper);
    }

    /**
     * 新增操作日志记录
     * 
     * @param projectOperLog 操作日志记录
     * @return 结果
     */
    @Override
    public int insertProjectOperLog(ProjectOperLog projectOperLog)
    {
        projectOperLog.setCreateBy(SecurityUtils.getUserId().toString());
        projectOperLog.setUpdateTime(DateUtils.getNowDate());
        projectOperLog.setUpdateBy(SecurityUtils.getUserId().toString());
        projectOperLog.setCreateTime(DateUtils.getNowDate());
        return projectOperLogMapper.insert(projectOperLog);
    }

    /**
     * 修改操作日志记录
     * 
     * @param projectOperLog 操作日志记录
     * @return 结果
     */
    @Override
    public int updateProjectOperLog(ProjectOperLog projectOperLog)
    {

        projectOperLog.setUpdateTime(DateUtils.getNowDate());
        projectOperLog.setUpdateBy(SecurityUtils.getUserId().toString());
        return projectOperLogMapper.updateById(projectOperLog);
    }

    /**
     * 批量删除操作日志记录
     * 
     * @param ids 需要删除的操作日志记录主键
     * @return 结果
     */
    @Override
    public int deleteProjectOperLogByIds(List<Long> ids)
    {
        return projectOperLogMapper.deleteBatchIds(ids);
    }

    /**
     * 删除操作日志记录信息
     * 
     * @param id 操作日志记录主键
     * @return 结果
     */
    @Override
    public int deleteProjectOperLogById(Long id)
    {
        return projectOperLogMapper.deleteById(id);
    }
}
